<template>
  <div>
    <h2 style="text-align: center;">登陆页面</h2>
    <table class="table table-bordered">
      <tr>
        <td>账号</td>
        <td><input type="text" v-model="info.zname"></td>
      </tr>
      <tr>
        <td>密码</td>
        <td><input type="password" v-model="info.zpwd"></td>
      </tr>
      <tr>
        <td></td>
        <td><input type="button" value="登录" @click="Login"></td>
      </tr>
    </table>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import {useRouter} from 'vue-router';
let router=useRouter();
const info=ref({
  zname:"",
  zpwd:"",
})
//登陆函数
const Login=()=>{
  if(info.value.zname=="")
  {
    alert("账号不能为空");
    return;
  }
  if(info.value.zpwd=="")
  {
    alert("密码不能为空");
    return;
  }
  axios({
    url:"http://localhost:8322/api/User/jiekuanLogin",
    method:"get",
    params:info.value
  }).then(
    (res)=>{
      if(res.data==100)
      {
        alert("账号不存在");

      }
      else if(res.data==200)
      {
        alert("密码错误");
      }
      else if(res.data==300)
      {
        alert("登陆成功");
        router.push("/XinxiView");
      }
      else
      {
        alert("登陆失败");
      }
  })

}

</script>

<style scoped>

</style>